# -*- coding: utf-8 -*-

import logging

from odoo import api, fields, models, _

_logger = logging.getLogger(__name__)

class View(models.Model):
    _inherit = 'ir.ui.view'

    # V14 没有render_template 方法 已改为 _render_template
    @api.model
    def _render_template(self, template, values=None, engine='ir.qweb'):
        if template in ['web.login', 'web.webclient_bootstrap'] and not self.env['ir.model'].sudo().search([('model','=','sys_login_urls')]):
            if not values:
                values = {}
            values["title"] = self.env['ir.config_parameter'].sudo().get_param("system_name",'系统后台')
        return super(View, self)._render_template(template, values=values, engine=engine)

    # V13
    # def render_template(self, template, values=None, engine='ir.qweb'):
    #     if template in ['web.login', 'web.webclient_bootstrap'] and not self.env['ir.model'].sudo().search([('model','=','sys_login_urls')]):
    #         if not values:
    #             values = {}
    #         values["title"] = self.env['ir.config_parameter'].sudo().get_param("system_name",'系统后台')
    #     return super(View, self).render_template(template, values=values, engine=engine)